package com.server.questionbank.snframe.util.FileUtil.lifecycle;

import com.server.questionbank.snframe.util.FileUtil.lifecycle.model.LifecycleRule;
import io.minio.messages.LifecycleConfiguration;

import java.util.ArrayList;
import java.util.List;

/**
 * 生命周期配置构建器
 */
public class LifecycleConfigurationBuilder {
    private final List<LifecycleRule> rules = new ArrayList<>();
    
    public LifecycleConfigurationBuilder addRule(LifecycleRule rule) {
        rules.add(rule);
        return this;
    }
    
    public LifecycleConfiguration build() {
        if (rules.isEmpty()) {
            throw new IllegalStateException("At least one rule is required");
        }
        
        List<io.minio.messages.LifecycleRule> minioRules = new ArrayList<>();
        for (LifecycleRule rule : rules) {
            minioRules.add(rule.toMinioRule());
        }
        
        return new LifecycleConfiguration(minioRules);
    }
} 